<?php global $has_permit; ?>
    <form action="<?php echo site_url('admin/medical/disease/index', true); ?>" method="post" id="frm_disease_search">
    <?php if ($has_permit) :?>
    <div class="std_header auto_height">
        <div class="left">
            <strong><?php echo $module['title']; ?></strong>
        </div>
        <div class="right">
            <?php if ($has_privilege_new) :?>
            <button type="button" class="gray_btn" onclick="window.location='<?php echo site_url('admin/medical/disease/edit', true); ?>'"><span>Thêm mới</span></button>
            <?php endif; ?>
        </div>
    </div>
    <div id="disease_management">
        <?php if (count($collection) != 0) : ?>
        <?php $paginator = $this->load->view('medical/disease/paginator', null, true); echo $paginator; ?>
        <?php endif; ?>
        <input type="hidden" name="current_page" id="current_page" value="<?php echo $current_page; ?>" />

        <?php $this->load->view('medical/disease/message'); ?>
            <div class="block">
                <table class="gridview" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <thead>
                    <tr>
                        <td><input id="check_all" type="checkbox" onclick="btn_util.check_all(this.checked, '.chk_id')" /></td>
                        <td><b>ID</b></td>
                        <td><b>Thông tin bệnh</b></td>
                    </tr>
                    </thead>
                    <tbody>
                        <tr class="filters">
                            <td colspan="3">
                                <input placeholder="ID" type="text" class="bind_enter_evt small_filter" name="filters[disease][id]" title="Tìm kiếm theo id của bệnh"  value="<?php echo isset($filters['disease']['id']) ? $filters['disease']['id'] : '' ; ?>" />
                                <input placeholder="Tên bệnh" style="margin-right: 10px; width: 170px;margin-left: 10px;" type="text"  name="filters[disease][name]" title="Tìm kiếm theo tên bệnh" value="<?php echo isset($filters['disease']['name']) ? $filters['disease']['name'] : '' ; ?>" />
                                <select name="filters[disease][object]" title="Đối tượng hay mắc bệnh" style="width: 130px;">
                                    <option value="0">Chọn đối tượng</option>
                                    <?php foreach ($list_object as $object) : ?>
                                    <option value="<?php echo $object->id; ?>" <?php if(isset($filters['disease']['object']) && $filters['disease']['object'] == $object->id):?> selected="selected" <?php endif ;?> ><?php echo $object->name; ?></option>
                                    <?php endforeach; ?>
                                </select>
                                <select name="filters[disease][department]" title="Bệnh thuộc khoa" style="width: 160px;">
                                    <option value="0">Thuộc khoa</option>
                                    <?php foreach ($department as $dep) : ?>
                                    <option value="<?php echo $dep->id; ?>"  <?php if (isset($filters['disease']['department']) && $filters['disease']['department'] == $dep->id) :?>selected="selected" <?php endif; ?> ><?php echo $dep->name; ?></option>
                                    <?php endforeach; ?>
                                </select>
                                <select name="filters[disease][season]" title="Thời tiết thường gặp" style="width: 80px;">
                                    <option value="0">Thời tiết</option>
                                    <?php foreach ($season as $sea) : ?>
                                    <option value="<?php echo $sea['id']; ?>" <?php if(isset($filters['disease']['season']) && $filters['disease']['season'] == $sea['id']):?> selected="selected" <?php endif ;?> ><?php echo $sea['name']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                                <select name="filters[disease][is_top]" title="Bệnh thường gặp hay không" style="width: 110px;">
                                    <option value="0">Thường gặp ko</option>
                                    <option value="1" <?php if(isset($filters['disease']['is_top']) && $filters['disease']['is_top'] == 1):?> selected="selected" <?php endif ;?> >Thường gặp</option>
                                    <option value="2" <?php if(isset($filters['disease']['is_top']) && $filters['disease']['is_top'] == 2):?> selected="selected" <?php endif ;?> >Bình thường</option>

                                </select>

                                <button class="gray_btn" type="button" onclick="return admin_medical_disease.act_filter()">
                                    <span>Lọc</span>
                                </button>
                                <button class="gray_btn" type="button" onclick="return admin_medical_disease.reset_filters('frm_disease_search')">
                                    <span>Xóa lọc</span>
                                </button>
                            </td>
                        </tr>
                        <?php if (count($collection) != 0) : ?>
                        <?php foreach ($collection as $disease) : ?>
                            <tr>
                                <input type="hidden" value="" class="edit_url" />
                                <td width="30px" valign="top">
                                    <input class="chk_id" type="checkbox" name="selected[]" value="<?php echo $disease->id; ?>" />
                                </td>
                                <td width="30px" valign="top">
                                    <?php echo $disease->id; ?>
                                </td>
                                <td valign="top">
                                    <div style="float: left;width: 100px;min-height: 100px;">
                                        <?php if (!empty($disease->image)) :?>
                                        <a target="_blank" href="<?php echo render_src($disease->image); ?>"><img src="<?php echo render_src($disease->image); ?>" width="50px" style="vertical-align: middle; border: 2px solid #bbb" /></a>
                                        <?php endif; ?>
                                    </div>
                                    <div style="float: left; width: 700px;margin-left: 10px;">
                                        <p style="margin-top: 5px;"><strong><a <?php if ($has_privilege_view) :?>href="<?php echo site_url('admin/medical/disease/edit/id/' . $disease->id, true); ?>"<?php endif; ?>><?php echo $disease->name; ?></a></strong></p>
                                        <p style="margin-top: 5px;">
                                            <strong>Số lần xem: </strong><?php echo $disease->views; ?>
                                            <?php if($disease->vote):?>
                                             - <strong>Đánh giá:</strong><?php echo $disease->vote; ?>
                                            <?php endif;?>
                                        </p>
                                        <p class="small_datetime" style="margin-top: 5px;">
                                            <?php echo $disease->short_description; ?>
                                        </p>
                                        <p style="margin-top: 5px;">
                                            <?php if ($has_privilege_view) :?>
                                            <a class="icon icon_edit" href="<?php echo site_url('admin/medical/disease/edit/id/' . $disease->id, true); ?>"></a>
                                            <?php endif; ?>
                                            <?php if ($has_privilege_delete) :?>
                                            <a class="icon icon_delete" href="<?php echo site_url('admin/medical/disease/delete/id/' . $disease->id, true); ?>" onclick="return confirm('Bạn muốn xóa khoa này?')"></a>
                                            <?php endif; ?>

                                            <?php if ($disease->is_hidden == 1) :?>
                                            <strong>Hiện</strong>
                                            <?php else :?>
                                            <strong style="color: red;">Ẩn</strong>
                                            <?php endif; ?>
                                        </p>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; ?>

                        <?php else : ?>
                            <tr>
                                <td colspan="3" style="padding: 10px">
                                    <p align="center">Danh sách bệnh trống trong thời điểm này hoặc truy vấn tìm kiếm không tìm thấy kết quả, <a href="<?php echo site_url('admin/medical/disease/filtered_list/' . $return_url, true); ?>">Thử lại</a></p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                    <tfoot>

                    </tfoot>
                </table>
            </div>


        <?php if (count($collection) != 0) : ?>
        <?php $paginator = $this->load->view('medical/disease/paginator', null, true); echo $paginator; ?>
        <?php endif; ?>

    </form>
    </div>
    <?php else :?>
        <?php $this->load->view('layouts/restricted'); ?>
    <?php endif; ?>

<div class="clearfix"></div>
<script type="text/javascript" src="<?php echo BASE_URL; ?>js/admin/medical/object/function.js"></script>

